package cn.com.guage.sort;

import java.util.Arrays;
import java.util.Random;

public class SortTest2 {

	public static void main(String[] args) {
		int[] array = getArray();
		System.out.println(Arrays.toString(array));
		int[] sortArray = sortArray(array);
		System.out.println(Arrays.toString(sortArray));

	}

	public static int[] getArray() {
		int[] array = new int[10];
		for (int i = 0; i < 10; i++) {
			int radom = new Random().nextInt(1000);
			array[i] = radom;
		}
		return array;
	}

	public static int[] sortArray(int[] array) {
		int[] result = new int[array.length];
		for (int i = 0; i < array.length; i++) {
			int temp = array[i];
			for (int j = i+1; j < array.length; j++) {
				if (temp > array[j + 1]) {
					temp = array[j + 1];
				}
			}
			result[i] = temp;
		}
		return result;
	}

}
